package com.tanhao.takeaway.commom;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;

@Data
public class R <T> implements Serializable {
    public Integer code;
    public String msg;
    public  T data;
    HashMap h=new HashMap<>();

    public static <T> R<T>  success(T t){
            R<T> r=new R<T>();
            r.code=1;
            r.data=t;
            return r;
    }

    public static <T> R<T> error(String msg){
        R r=new R();
        r.code=0;
        r.msg=msg;
        return r;
    }

    public R<T> add(String key,Object value){
         this.h.put(key,value);
         return this;
    }
}
